package com.ebupt.migu.music.schedule.controller;

import com.ebupt.migu.music.schedule.service.PTTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 白金会员短信推送
 * @author: liuyangyang@ebupt.com
 * @date: 2021/1/13 11:07
 */
@Slf4j
@Async
@Component
@RestController
@EnableScheduling
public class PTTask {

    @Autowired
    private PTTaskService ptTaskService;

    /**
     * 发送短信【每天早八点到晚八点，每十分钟扫描一次表】
     */
    @Scheduled(initialDelay = 1000, fixedDelay = 1000 * 60)
    public void sendMessageNow() throws Exception {
        log.info("白金会员短信推送定时任务启动");
        ptTaskService.send_pt_message();
        log.info("白金会员短信推送定时任务结束");
    }
}
